package com_atguigu_sprinboot.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class ProducerController {
    @Autowired
    KafkaTemplate kafkaTemplate;

    @RequestMapping("/atguigu")
    public String data(String msg){
        //通过kafka发送数据
        kafkaTemplate.send("first",msg);
        log.info("发送消息成功");
        return "ok";
    }
}
